/**
 * User: ShenBo
 * Created on: 2009-5-28, 20:03:11
 */

package shenbo.fetionlib;

import shenbo.fetionlib.action.AuthenticateAction;

import java.io.IOException;

public class FetionClient {
    
    private FetionAccount fetionAccount;

    private FetionConnection fetionConnection;

    public FetionClient(FetionAccount fetionAccount) {
        this.fetionAccount = fetionAccount;
        this.fetionConnection = new FetionConnection();
    }

    public FetionClient(FetionAccount fetionAccount, String ssiUrl) {
        this.fetionAccount = fetionAccount;
        this.fetionConnection = new FetionConnection(ssiUrl);
    }

    private FetionConnection getFetionConnection() {
        if (this.fetionConnection == null) {
            this.fetionConnection = new FetionConnection();
        }

        return this.fetionConnection;
    }

    public void login() throws IOException {
        FetionConnection conn = getFetionConnection();
        conn.executeAction(new AuthenticateAction(this.fetionAccount));

    }
}
